<template>
  <div>
    <div style="padding-top:40px;">
      <image src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1543143098184&di=6dbe3f010286368a58904e26ddc351e7&imgtype=0&src=http%3A%2F%2Fstatic.jisujie.com%2Fwp-content%2Fuploads%2F1534851948312.jpg" class="Banner"></image>
      <div>
        <div class="btn">
          <div style="width:50%;text-align:center;" @click="showModalStatus = !showModalStatus">
            <van-icon name="question" size="15px" custom-style="position:relative;top:2px;right:5px;" />拼团规则
          </div>
          <div style="width:50%;text-align:center;border-left:1px solid #909090;" @click="handleGroup()"> 
            <van-icon name="contact" size="15px" custom-style="position:relative;top:2px;right:5px;" />我的拼团
          </div>
        </div>
        <div class="group-item" v-for="(item,index) in fight_group_tpls" :key="index">
          <image :src="item.picture_url" class="Banner"></image>
          <div style="font-size:14px;font-weight:bold;padding-left:10px;padding-rigth:10px;">{{item.product_name}}</div>
          <div style="padding:10px;">
            <span style="color:#FFB3BB;font-size:17px;">￥{{item.price/100}}</span>
            <span style="color:#FFB3BB;font-size:13px;text-decoration:line-through;padding-left:10px;">￥{{item.original_price/100}}</span>
            <span style="color:#909090;font-size:14px;padding-left:15px;">{{item.people_num}}人团</span>
            <div class="group-btn" @click="handleLaunchGroup(item)">去拼团</div>
          </div>
        </div>
      </div>
    </div>
    <!--弹框-->
    <div class="drawer_screen" v-if="showModalStatus"></div>
    <div class="drawer_box_ad" v-if="showModalStatus">
      <div class="drawer_title">
        拼团规则
        <image @click="showModalStatus = !showModalStatus" src="/static/assets/close.png" class="close-img"></image>
      </div>
      <div class="drawer_item">1.点击“去拼团”参加拼团活动。</div>
      <div class="drawer_item">2.分享至微信群或发送给微信好友，邀请好友参团。</div>
      <div class="drawer_item">3.达到该拼团要求的成团人数，则拼团成功，点击“立即查看”可领取相应奖励。</div>
      <div class="drawer_item" style="padding-bottom:20px;">4.有效时间内未达到要求人数，则拼团失败。</div>
    </div>
  </div>
</template>

<script>
import api from '@/utils/api'
import { mapState, mapActions ,mapGetters } from 'vuex'
export default {
  data () {
    return {
      showModalStatus:false,
    }
  },
  computed: {
    ...mapGetters([
      'user',
      'fight_group_tpls',
    ]) 
  },
  methods: {
    ...mapActions([
      'fetchFightGroupTpls'
    ]),
    handleGroup(){
      wx.navigateTo({url: '/pages/activity/group/my_group'})
    },
    handleLaunchGroup(fight_group_tpl){
      wx.navigateTo({url: '/pages/activity/group/launch_group?group_tpl_id=' + fight_group_tpl.id})
    }
  },
  mounted () {
    this.fetchFightGroupTpls({brand_id: this.user.brand_id, page:0, limit:10})
  },
}
</script>

<style scoped>
.Banner{
  height:200px;
  width: 100%;
}
.btn{
  position: relative;
  top:-25px;
  left: 10%;
  height: 30px;
  line-height: 30px;
  width:80%;
  color: #909090;
  font-size: 15px;
  background: #FFF;
  border-radius:25px;
  display: flex;
  padding-top: 10px;
  padding-bottom: 10px;
  z-index: 1000;
}
.icon{
  position: relative;
  top: 10px;
}
.group-item{
  width: 90%;
  margin: 0px auto 20px auto;
  border-radius: 10px;
  overflow: hidden;
  background: white;
}
.group-btn{
  display: inline-block;
  float: right;
  background: #FEB3BA;
  font-size: 15px;
  height: 30px;
  line-height: 30px;
  border-radius: 15px;
  width: 70px;
  text-align: center;
}
.drawer_screen {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background: #000;
  opacity: 0.5;
  overflow: hidden;
}
.drawer_box_ad {
  margin-left: 6%;
  width: 88%;
  position: fixed;
  top: 30%;
  z-index: 1001;
  background: #FFF;
  border-radius: 10px;
}
.drawer_title{
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 16px;
  border-bottom: 1px solid #F9F9F9;
}
.close-img{
  float: right;
  width: 34px;
  height: 34px;
  padding-top: 3px;
  padding-right: 10px;
}
.drawer_item{
  padding: 15px 15px 0 15px;
  font-size: 16px;
}
</style>
